package com.zjw.algorithm;


import java.util.concurrent.CountDownLatch;

/**
 *
 */
public class Solution15 {

    static class Foo {


        private final CountDownLatch ca = new CountDownLatch(1);
        private final CountDownLatch cb = new CountDownLatch(1);

        public Foo() {

        }

        public void first(Runnable printFirst) throws InterruptedException {

            // printFirst.run() outputs "first". Do not change or remove this line.
            printFirst.run();
            ca.countDown();
        }

        public void second(Runnable printSecond) throws InterruptedException {
            ca.await();
            // printSecond.run() outputs "second". Do not change or remove this line.
            printSecond.run();
            cb.countDown();
        }

        public void third(Runnable printThird) throws InterruptedException {

            cb.await();
            // printThird.run() outputs "third". Do not change or remove this line.
            printThird.run();
        }
    }

}



